/*
 * Copyright (c) 2010-2013 Ruben Chakhmakhchyan. All rights reserved.
 * 
 * This file contains Original Code and/or Modifications of Original Code
 * as defined in and that are subject to the Eclipse Public License
 * Version 1.0 (the 'License'). You may not use this file except in
 * compliance with the License. Please obtain a copy of the License at
 * http://opensource.org/licenses/EPL-1.0 and read it before using this file.
 */

#pragma once

#include "stdafx.h"
#include "list.h"
#include "commontypes.h"
#include "variant.h"


typedef enum JsArrayType
{
	JsArray,
	JsUint8Array,
	JsInt8Array,
} JsArrayType;


template<typename T>
HRESULT fillIntArray( IDispatch* a, List<T>& list );

HRESULT pushArray( IDispatch* a, VARIANT& value );

template<typename T>
HRESULT pushNumericArray( IDispatch* a, enum VARENUM vt, T value );

IDispatch* listToArray( IWebBrowser2* browser, List<byte_t>& list );

HRESULT newArray( JsArrayType arrayType, IWebBrowser2* wb, IDispatch** a, int length = 0 );

bool variantToArray( const VARIANT* pArray, List<VARIANT>*& pItems );

BSTR charToBstr( const char* cstring );
char* bstrToChars( BSTR string );
